﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using QuickTasks;

namespace LocalSettings
{
    public static class IsolatedSettings
    {
        public static void saveSettings(string keyname, string keyvalue)
        {
            try
            {
                var settings = IsolatedStorageSettings.ApplicationSettings;
                if (settings.Contains(keyname))
                    settings[keyname] = keyvalue;
                else
                    settings.Add(keyname, keyvalue);
                settings.Save();
                
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in saveSettings method In IsolatedSettings file", ex);
            }
        }

        public static string getSettingsStringValue(string keyname)
        {
            string keyvalue = "";
            try
            {
               
                var settings = IsolatedStorageSettings.ApplicationSettings;
                if (settings.Contains(keyname))
                    keyvalue = settings[keyname].ToString();
                return keyvalue;
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in getSettingsStringValue method In IsolatedSettings file", ex);
                return keyvalue;
            }
        }

        public static bool getSettingsBoolValue(string keyname)
        {
            bool keyvalue = false;
            try
            {
              
                var settings = IsolatedStorageSettings.ApplicationSettings;
                if (settings.Contains(keyname))
                    keyvalue = Convert.ToBoolean(settings[keyname].ToString());
                return keyvalue;
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in getSettingsBoolValue method In IsolatedSettings file", ex);
                return keyvalue;
            }
        }
        public static int getSettingsintValue(string keyname)
        {
            int keyvalue = 0;
            try
            {
               
                var settings = IsolatedStorageSettings.ApplicationSettings;
                if (settings.Contains(keyname))
                    keyvalue = Convert.ToInt32(settings[keyname].ToString());
                return keyvalue;
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in getSettingsintValue method In IsolatedSettings file", ex);
                return keyvalue;
            }
        }
    }
}
